from openvino.runtime import Core
import numpy as np
from sklearn.preprocessing import MinMaxScaler
ie = Core()
devices = ie.available_devices
#读取模型
model = ie.read_model(model='saved_model.xml')
compiled_model = ie.compile_model(model=model, device_name="CPU")
input_layer = next(iter(compiled_model.inputs))
output_layer = next(iter(compiled_model.outputs))
print("训练模型加载完毕")
#获取近10天收盘价
zq_code = input("请输入要预测的股票代码:")
from jqdatasdk import *
auth('13912967392','Zcxvbmn1')
dataframe = get_bars(normalize_code(zq_code), 11, unit='1d', fields=['date', 'close']).set_index('date')
print("已获取"+zq_code+"近10日数据!!!!")
dataset = []
price = dataframe.values.astype('float32')
for i in range(len(dataframe)-1):
    dataset.append((price[i+1]-price[i])/price[i])
scaler = MinMaxScaler(feature_range=[0,1])
input_data = np.array(scaler.fit_transform(dataset))
input_data = np.expand_dims(input_data, axis=0)
result = compiled_model([input_data])[output_layer]
print("预计下一个交易日的涨跌幅为"+str(round(scaler.inverse_transform(result)[0][0]*100,3))+"%")
print("股市有风险，请谨慎！")